//
//  AddCarCell.m
//  saler-ios
//
//  Created by 王亚陆 on 17/6/5.
//  Copyright © 2017年 sayimba. All rights reserved.
//

#import "AddCarCell.h"

@implementation AddCarCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        
        
        self.contentView.backgroundColor = WhiteColor;
        _SmallImage = [[UIImageView alloc]init];
        [self.contentView addSubview:_SmallImage];
        [_SmallImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(25*kWidth);
            make.size.mas_equalTo(CGSizeMake(20*kWidth, 20*kHeight));
        }];
        _CarName = [self createUIlabel:@"宝马-宝马系列2系" andFont:FontOfSize13 andColor:AddCarColor];
        [self.contentView addSubview:_CarName];
        [_CarName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.left.mas_equalTo(self.contentView.mas_left).with.offset(56*kWidth);
            make.width.mas_equalTo(Main_Width*0.65);
        }];
       self.ReduceImage = [[UIImageView alloc]init];
        self.ReduceImage.image = [UIImage imageNamed:@"reduce"];
        [self.contentView addSubview:self.ReduceImage];
        [self.ReduceImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.mas_equalTo(self.contentView.mas_right).with.offset(-50*kWidth);
            make.size.mas_equalTo(CGSizeMake(21*kWidth, 21*kHeight));
        }];
        
        _deleteBtn = [NewBtn buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_deleteBtn];
        [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.mas_equalTo(self.contentView.mas_right).with.offset(-35*kWidth);
            make.size.mas_equalTo(CGSizeMake(50*kWidth, 30*kHeight));
        }];
        
        _CarNumber = [self createUIlabel:@"1辆" andFont:FontOfSize13 andColor:AddCarColor];
        [self.contentView addSubview:_CarNumber];
        [_CarNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.mas_equalTo(self.ReduceImage.mas_left).with.offset(-15*kWidth);
        }];
        
        UIView * Hline1 =[[UIView alloc]init];
        Hline1.backgroundColor = GrayColor;
        [self.contentView addSubview:Hline1];
        [Hline1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right);
            make.bottom.mas_equalTo(self.contentView.mas_bottom).with.offset(0.5*kHeight);
            make.size.mas_equalTo(CGSizeMake(308*kWidth, 1*kHeight));
        }];
        
        
        self.PlusImage = [[UIImageView alloc]init];
        self.PlusImage.image = [UIImage imageNamed:@"plus"];
        [self.contentView addSubview:self.PlusImage];
        [self.PlusImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.mas_equalTo(_CarNumber.mas_left).with.offset(-15*kWidth);
            make.size.mas_equalTo(CGSizeMake(21*kWidth, 21*kHeight));
        }];
        
        _addBtn = [NewBtn buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:_addBtn];
        [_addBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.contentView.mas_centerY);
            make.right.mas_equalTo(self.PlusImage.mas_right);
            make.size.mas_equalTo(CGSizeMake(50*kWidth, 30*kHeight));
        }];

    }
    return self;
    
}
-(NewBtn*)createBtn:(NSString*)title {
    
    NewBtn * btn = [NewBtn buttonWithType:UIButtonTypeCustom];
    
    return btn;
}

-(UILabel*)createUIlabel:(NSString *)title andFont:(CGFloat)font andColor:(UIColor*)color {
    UILabel * label =[[UILabel alloc]init];
    label.text = title;
    label.textColor = color;
    UIFont *fnt = [UIFont fontWithName:@"HelveticaNeue" size:font];CGSize size = [label.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:fnt,NSFontAttributeName, nil]];
    // 名字的H
    CGFloat nameH = size.height;
    // 名字的W
    CGFloat nameW = size.width;
    label.textAlignment = NSTextAlignmentLeft;
    label.frame =CGRectMake(0, 0, nameW, nameH);
    label.font = Font(font);
    return label;
}




- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
